/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Penjadwalan;

import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author admin
 */
public class PenjadwalanTabelModel extends AbstractTableModel {

    private List<Penjadwalan> jadwal = new ArrayList<Penjadwalan>();

    public PenjadwalanTabelModel(List<Penjadwalan> jadwal) {
        this.jadwal = jadwal;
    }

    public void delete(int row) {
        jadwal.remove(row);
        fireTableRowsDeleted(row, row);
    }

    public void update(int row, Penjadwalan jl) {
        jadwal.set(row, jl);
        fireTableRowsUpdated(row, row);
    }

    public int getRowCount() {
        return jadwal.size();
    }

    public int getColumnCount() {
        return 6;
    }

    public Object getValueAt(int rowIndex, int columnIndex) {
        Penjadwalan j = jadwal.get(rowIndex);
        switch (columnIndex) {
            case 0:
                return j.getHari();
            case 1:
                return j.getJam();
            case 2:
                return j.getKelas();
            case 3:
                return j.getIdMakul().getIdmatakuliah();
            case 4:
                return j.getIdDosen().getId_dosen();
            case 5:
                return j.getIdRuang().getId_ruang();
            default:
                return "";
        }
    }

    @Override
    public String getColumnName(int column) {
        switch (column) {
            case 0:
                return "Hari";
            case 1:
                return "Jam";
            case 2:
                return "Kelas";
            case 3:
                return "Id Matakuliah";
            case 4:
                return "Id Dosen";
            case 5:
                return "Id Ruang";
            default:
                return "";

        }
    }
}
